/*--------------------------------------------------------------
 * File: demo41.c 编码类型：C语言  UTF-8
 * Author WRS (1352509846@qq.com)
 * 功能: 字符串翻转
 * Version 0.1
 * Date 2022-03-26 
 * 
 * @copyright Copyright (c) 2022
 * 
----------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>

char* reverSentence(char *str)
{
    int i = 0;
    int j = strlen(str)-1;
    char temp = 0;

    while(i<j)
    {
        temp = *(str+i);
        *(str+i) = *(str+j);
        *(str+j) = temp;
        i++;
        j--;
    }
    return str;
}

int main(int argc, char const *argv[])
{
    char str[30] = {0};

    printf("请输入一个字符串:");
    scanf("%s",str);
    printf("输入的字符串为%s\n",str);
    printf("翻转后的字符串为%s\n",reverSentence(str));

    return 0;
}

